package com.tianpengtech.common.validator.rules.numberic;

import com.tianpengtech.common.exception.ValidateException;
import com.tianpengtech.common.validator.AbstractRule;

public class NumbericMustBetween extends AbstractRule {

    private long min;
    private long max;

    public NumbericMustBetween(long v, String msg, long min, long max) {
        this.value = v;
        this.msg = msg;
        this.min = min;
        this.max = max;
    }

    @Override
    public boolean validate() throws ValidateException {

        long v = (Long) this.value;
        if (v < this.min || v > this.max) {
            throw new ValidateException(this.msg);
        }
        return true;
    }
}
